﻿using System.Data;
using Microsoft.Practices.EnterpriseLibrary.Data;

namespace Koonsoft.HYCRM.DAL
{
    public class YearAuditDAL
    {
        private Database database = DatabaseFactory.CreateDatabase("KOONCRMDB");

        /// <summary>
        /// 导出待年检记录
        /// </summary>
        /// <param name="month">月份</param>
        /// <param name="branchID">分行编号</param>
        /// <returns></returns>
        public DataTable GetAnnualCheckMissions(int month, int branchID,int year)
        {
            const string procedure = "AnnualCheck_FillRecord";

            using (var cmd = database.GetStoredProcCommand(procedure))
            {
                database.AddInParameter(cmd, "@month", DbType.Int32, month);
                database.AddInParameter(cmd, "@branchID", DbType.Int32, branchID);
                database.AddInParameter(cmd, "@year", DbType.Int32, year);
                return database.ExecuteDataSet(cmd).Tables[0];
            }
        }

        /// <summary>
        /// 按工号获得员工待办的年检任务
        /// </summary>
        /// <param name="employeeID"></param>
        /// <returns></returns>
        public DataTable GetYearAuditTasksByEmpolyeeID(int employeeID)
        {
            const string procedure = "task_GetMyTasks";

            using (var cmd = database.GetStoredProcCommand(procedure))
            {
                database.AddInParameter(cmd, "@empolyeeid", DbType.Int32, employeeID);
                return database.ExecuteDataSet(cmd).Tables[0];
            }
        }
    }
}
